#include <list>
using std::list;
#include <vector>
using std::vector;
#include <list>
using std::list;
#include <iostream>
using std::cout;
using std::endl;


struct ListNode{
    int val;
    ListNode* next;
    // ListNode(int v): val(v), next(nullptr) {};
    ListNode(int v = 0, ListNode* nxt = nullptr): val(v), next(nxt) {};
};


ListNode* create_list(vector<int> arr){
    ListNode head;
    ListNode* pcur = &head;
    for(int i = 0; i < arr.size(); ++i){
        pcur->next = new ListNode(arr[i]);
        pcur = pcur->next;
    }
    return head.next;
}

ListNode* create_list(int* vals, int size){
    ListNode head;
    ListNode* pcur = &head;
    for(int i = 0; i < size; ++i){
        pcur->next = new ListNode(vals[i]);
        pcur = pcur->next;
    }
    return head.next;
}

void show(ListNode* t){
    while(t != nullptr){
        cout << t->val << " ";
        t = t->next;
    }
    cout << endl;
}

void show(const list<int>& data){
    for(auto& e: data){
        cout << e << " ";
    }
    cout << endl;
}

ListNode * simple_list()
{
    int arr[10] = {1,2,3,6,8,9};
    return create_list(arr, 6);
}

ListNode * simple_list_2()
{
    int arr[10] = {1,5,7,10};
    return create_list(arr, 4);
}
